package speedball.start;

import javafx.animation.FadeTransition;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.util.Duration;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class StartAnimationApplication extends Application {

    private static String repath="/img/logo/";
    private static List<String> logoFiles=new ArrayList<>();

    static{
        logoFiles.add(repath+"5cf516b92f288b009d620425.png");
        logoFiles.add(repath+"5cf516ba9514c6005704a384.png");
        logoFiles.add(repath+"5cf516bc2f288b009f37a427.png");
        logoFiles.add(repath+"5cf516ca2f288b009f37a435.png");
        logoFiles.add(repath+"5cf516ce12d6c900622b768a.png");
        logoFiles.add(repath+"5cf516d02f288b009d62043c.png");
        logoFiles.add(repath+"5cf516d12f288b009e7c2f79.png");
//        logoFiles.add("5cf522749514c60058ad60c6.png");
//        logoFiles.add("5cf5228c2f288b009d6207cb.png");
//        logoFiles.add("5cf522942204c5002aa19469.png");
//        logoFiles.add("5cf522a54a6a1000989b6ce5.png");
//        logoFiles.add("5cf523fa12d6c90058921f63.png");
    }
public StartAnimationApplication(){

}

    @Override
    public void start(Stage primaryStage) throws Exception {

//        StartAnimation startAnimation=new StartAnimation();
//
//        startAnimation.initOwner(primaryStage);
//        startAnimation.show();

//        FXMLLoader myMenufXMLLoader = new FXMLLoader(getClass().getClassLoader().getResource("./fxml/ui/logo.fxml"));
//        Parent root2 = myMenufXMLLoader.load();
//        Scene scene=new Scene(root2);
//        scene.setFill(Color.TRANSPARENT);
//        primaryStage.setScene(scene);
//        primaryStage.setAlwaysOnTop(true);
//        primaryStage.setWidth(500D);
//        primaryStage.setHeight(500D);
//        primaryStage.initStyle(StageStyle.TRANSPARENT);
//        primaryStage.show();


        FXMLLoader myMenufXMLLoader4 = new FXMLLoader(getClass().getClassLoader().getResource("./fxml/ui/Spinner.fxml"));
            Parent root24 = null;

            root24 = myMenufXMLLoader4.load();

        ImageView imageView = new ImageView();
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if (w < 0){w = 0;}

        System.out.println(w);
        imageView.setImage(new Image(logoFiles.get(w)));


        StackPane stackPane=(StackPane)root24;
        stackPane.getChildren().add(imageView);

        FadeTransition imageViewFade = new FadeTransition(Duration.millis(2000), imageView);
        imageViewFade.setFromValue(0.0);
        imageViewFade.setToValue(1.0);
        imageViewFade.setCycleCount(2);
        imageViewFade.setAutoReverse(true);
        imageViewFade.play();


            Scene scene=new Scene(root24);
            scene.setFill(Color.TRANSPARENT);
            primaryStage.setScene(scene);
            primaryStage.setAlwaysOnTop(true);
            primaryStage.setWidth(500D);
            primaryStage.setHeight(500D);
            primaryStage.initStyle(StageStyle.TRANSPARENT);
            primaryStage.show();







    }


}
